package consul;

import com.google.gson.Gson;
import consul.allinone.discovery.ConsulSubscirbeService;
import consul.allinone.discovery.RpcClientInvokerCache;
import consul.allinone.discovery.SubscirbeService;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

/**
 * Title:
 * Description:
 * Author:吉
 * Since:2018/4/13
 * Version:1.1.0
 */
public class MainSubscriber {

    public static void main(String[] args) throws IOException, InterruptedException {
        SubscirbeService subscirbeService = new ConsulSubscirbeService();
        subscirbeService.subscribe("192.168.56.200", 8500, "mockNotice");
//        System.out.println(new Gson().toJson(subscirbeService));
        while (true) {
            System.out.println(new Gson().toJson(RpcClientInvokerCache.getConnectedHandlersClone()));
            TimeUnit.SECONDS.sleep(2);
        }
    }
}
